<template>
	<view>
		<u-navbar title-color="#333" title-bold title-size="36" title="优惠券" :border-bottom="false"></u-navbar>
		<view class="">
			<u-tabs active-color="#FC3A30" height="88" :list="list" :is-scroll="false" :current="current"
				@change="change"></u-tabs>
		</view>
		<view class="flex flex_end lqzx" @click="tocenter">
			进入领券中心
		</view>
		<view class="yhq-div">
			<view class="yhq-item flex" :class="item.status==2?'yhq-item-sel':''" v-for="(item,index) in datalist" :key="index">
				<view class="i-left flex flex_cen" >
					<view class="yuan1"></view>
					<view class="yuan2"></view>
					<view class="text_center">
						<view class="">
							<span class="n-fh">￥</span>
							<span class="m-num">{{item.jian_price}}</span>
						</view>
						<view class="manjian">
							满{{item.man_price}}元可用
						</view>
					</view>
					
				</view>
				<view class="i-right flex flex_sb">
					<view class="">
						<view class="y-mc">
							{{item.title}}
						</view>
						<view class="y-yxq">
							有效期至{{item.e_time}}
						</view>
					</view>
					<image v-if="item.status==2" class="yhq-img" src="../../static/img/home/yhq-1.png" mode=""></image>
					<image v-else-if="item.status==3" class="yhq-img" src="../../static/img/home/yhq-2.png" mode=""></image>
					<view v-else class="y-btn" @click="touse">
						去使用
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '全部'
				}, {
					name: '未使用'
				}, {
					name: '已使用',
				}, {
					name: '已失效',
				}],
				current: 0,
				datalist:[],
				type:''
			}
		},
		onLoad(e) {
			this.type = e.type
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				this.$api({
					url: '/myYhqList',
					method: 'get',
					data: {
						token: uni.getStorageSync("token"),
						status:this.current,
						type:this.type
					},
				}).then(res => {
					if (res.code == 1) {
						this.datalist=res.data.list
					}
				})
			},
			change(index) {
				this.datalist = []
				this.current = index;
				this.getList()
			},
			tocenter(){
				uni.navigateTo({
					url:"/pages/mine/youhuiquanCenter?type="+this.type
				})
			},
			touse(){
				if(this.type==1){
					uni.reLaunch({
						url:"/pages/index/index"
					})
				}else{
					uni.reLaunch({
						url:"/subPackageA/pages/lawyerVersion/index/index"
					})
				}
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.lqzx {
		font-size: 24rpx;
		color: #FF5300;
		text-decoration-line: underline;
		padding: 32rpx;
	}
	.yhq-div{
		
		.yhq-item{
			overflow: hidden;
			width: 686rpx;
			height: 200rpx;
			background: #FFFFFF;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin: 0 auto;
			margin-bottom: 20rpx;
			
			
			
			.i-left{
				width: 240rpx;
				height: 200rpx;
				background: linear-gradient( 134deg, #FE5C3D 0%, #F3152E 100%);
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				position: relative;
				color: #FFFFFF;
				.yuan1{
					position: absolute;
					top: -13rpx;
					right:  -13rpx;
					width: 26rpx;
					height: 26rpx;
					border-radius: 50%;
					background-color: #FFFFFF;
				}
				.yuan2{
					position: absolute;
					bottom: -13rpx;
					right:  -13rpx;
					width: 26rpx;
					height: 26rpx;
					border-radius: 50%;
					background-color: #FFFFFF;
				}
				
				.n-fh{
					font-weight: bold;
					font-size: 36rpx;
					
				}
				.m-num{
					font-weight: bold;
					font-size: 52rpx;
					
				}
				.manjian{
					font-size: 24rpx;
					
				}
			}
			.i-right{
				padding: 28rpx 20rpx;
				width: 446rpx;
				.y-mc{
					font-size: 32rpx;
					color: #333333;
				}
				.y-yxq{
					font-size: 24rpx;
					color: #666666;
					margin-top: 20rpx;
				}
				.y-btn{
					width: 136rpx;
					height: 56rpx;
					background: #FFFFFF;
					border-radius: 30rpx 30rpx 30rpx 30rpx;
					border: 2rpx solid #ADADAD;
					font-size: 28rpx;
					color: #696969;
					text-align: center;
					line-height: 56rpx;
				}
				
				.yhq-img{
					width: 120rpx;
					height: 120rpx;
				}
			}
			
			
			&-sel{
				.i-left{
					background: #EBEBEB;
					color: #BABABA;
				}
				.i-right{
					.y-mc{
						font-size: 32rpx;
						color: #BABABA;
					}
					.y-yxq{
						font-size: 24rpx;
						color: #BABABA;
						margin-top: 20rpx;
					}
				}
			}
		}
	}
</style>